﻿@model MvcApplication1.Models.Category
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
<h2>@Model.CategoryName</h2>
@if (Model.SubCategoryList != null && Model.SubCategoryList.Count() != 0)
{
    <h4>Subcategory List</h4>
    <ul>
    @foreach (var subCats in Model.SubCategoryList)
    {
        <li>@Html.ActionLink(subCats.CategoryName, "Browse", new { id = subCats.CategoryID })</li>
    }
    </ul>
}
@if (Model.Products != null && Model.Products.Count != 0)
{
    <h4>Product List</h4>
    <ul>
    @foreach (var product in Model.Products)
    {
        <li>@Html.ActionLink(product.ProductName, "Details", new { id = product.ProductID })</li>
    }
    </ul>
}
<div class="pager">
@{var pageCount = (int)Math.Ceiling((double)Model.SubCategoryCount / (int)ViewData["CategoriesPerPage"]);
  }
@if (pageCount > 1) {
    for (int i = 1; i <= pageCount; i++)
    {
        @Html.ActionLink(i.ToString(),
                @Url.RequestContext.RouteData.GetRequiredString("Action"),
                new { cpage = i })
    }
}
</div>
@ViewBag.Mess
